package cn.com.pc.content.dto;

import cn.com.pc.content.domain.article.Article;
import lombok.Data;
import lombok.EqualsAndHashCode;
import lombok.ToString;
import org.springframework.beans.BeanUtils;

import javax.validation.constraints.NotBlank;

/**
 * 文章表单
 */
@EqualsAndHashCode(callSuper = true)
@Data
@ToString(callSuper = true)
public class ArticleDTO extends ContentDTO {

    @NotBlank(message = "text不能为空")
    private String text;

    public static ArticleDTO from(Article article) {
        ArticleDTO articleDTO = new ArticleDTO();
        BeanUtils.copyProperties(article, articleDTO);
        return articleDTO;
    }
}
